<html>
  <head>
    <script src="../ejs.js"></script>
    <script id="users" type="text/template">

      <$ if (names.length) { $>
        <h1><$=:names|first$></h1>
        <ul>
          <$ names.forEach(function(name){ $>
            <li><$=: name|haha |notEmpy |aaa:10 $></li>
          <$ }) $>
        </ul>
      <$ } $>
    </script>
    <script>
    ejs.delimiter = '$';
    ejs.filters.haha=function (x) {
      return x+"haha";
    }
    ejs.filters.notEmpy=function (x) {
      return x.length>5?"haha":"hehe";
    }

     ejs.filters.aaa=function (x,a) {
      return x+a;
    }

      onload = function(){
        var users = document.getElementById('users').innerHTML;
        var names = ['zhangsan', 'fdafdssas', 'fdsafd'];
        var html = ejs.render(users, { names: names });
        document.body.innerHTML = html;
      }
    </script>
  </head>
  <body>
  </body>
</html>